package com.nf.health.app.inquiry.adapter;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.nf.health.app.R;
import com.nf.health.app.inquiry.bean.MySeltctPayTime;
import com.nf.health.app.utils.ImageUtils;

import java.util.List;

/**
 * Created by Jason on 2016/10/11.
 */
public class SelectServiceDataTypeAdapter extends BaseAdapter {
    private List<MySeltctPayTime> list;
    private Context cnt;
    private LayoutInflater layoutinflater;


    public SelectServiceDataTypeAdapter(Context cnt, List<MySeltctPayTime> list){
        this.cnt = cnt;
        this.list = list;
        layoutinflater = LayoutInflater.from(cnt);
    }
    public void setMyNotifyDataChanged (List<MySeltctPayTime> list){
        this.list = list;
        notifyDataSetChanged();
    }
    @Override
    public int getCount() {
        return  list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if(convertView == null){
            convertView = layoutinflater.inflate(R.layout.item_my_small_gv,null);
            viewHolder = new ViewHolder();
            viewHolder.tv_item_status_satified = (TextView) convertView.findViewById(R.id.tv_item_status_satified);
            convertView.setTag(viewHolder);
        }else{
            viewHolder = (ViewHolder) convertView.getTag();
        }
        MySeltctPayTime mySelectpayTime = list.get(position);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(120,80);
        layoutParams.setMargins(10, 5, 10, 5);//4个参数按顺序分别是左上右下搜索
        viewHolder.tv_item_status_satified.setLayoutParams(layoutParams);
        viewHolder.tv_item_status_satified.setGravity(Gravity.CENTER);
        if(mySelectpayTime.isClick()) {
            ImageUtils.setTextViewBg(viewHolder.tv_item_status_satified, cnt, R.drawable.shade_full_oval_small, mySelectpayTime.getSelestDate());
            viewHolder.tv_item_status_satified.setTextColor(cnt.getResources().getColor(R.color.white));
        }else{
            ImageUtils.setTextViewBg(viewHolder.tv_item_status_satified, cnt, R.drawable.shade_enpety_oval_small, mySelectpayTime.getSelestDate());
            viewHolder.tv_item_status_satified.setTextColor(cnt.getResources().getColor(R.color.theme_color));
        }
        return convertView;
    }
    private class ViewHolder{
    private TextView tv_item_status_satified;
    }
}
